//
//  MainMenuViewController.m
//  GR8_Iphl
//
//  Created by Tim Linsen on 11/01/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "MainMenuViewController.h"
#import "AfwDocViewController.h"
#import "BbmViewController.h"
#import "PlattegrondViewController.h"
#import "ExaViewController.h"
#import "DieViewController.h"
#import "DagViewController.h"
#import "UurViewController.h"
@implementation MainMenuViewController
@synthesize afwDoc;
@synthesize bbm;
@synthesize plattegrond;
@synthesize exa;
@synthesize die;
@synthesize dag;
@synthesize uur;

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    array = [[ NSMutableArray alloc] init];
    [array addObject:@"Afwezige lectoren"];
    [array addObject:@"Blackboard"];
    [array addObject:@"Dagmenu"];
    [array addObject:@"Examenrooster"];
    [array addObject:@"Diensten"];
    [array addObject:@"Plattegrond"];
    [array addObject:@"Uurrooster"];
    
    self.title = @"iPHL";
    
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
 
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
    // Return the number of rows in the section.
    return [array count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    cell.textAlignment = UITextAlignmentCenter;
    cell.textLabel.text = [array objectAtIndex:indexPath.row];
    
    UIImage *afwdocImage = [UIImage imageNamed:@"kruis.jpg"];
    UIImage *bbImage = [UIImage imageNamed:@"bb.jpg"];
    UIImage *dagImage = [UIImage imageNamed:@"eet.jpg"];
    UIImage *exaImage = [UIImage imageNamed:@"kalender.jpg"];
    UIImage *dieImage = [UIImage imageNamed:@"klok.jpg"];
    UIImage *plattegrondImage = [UIImage imageNamed:@"map.jpg"];
    UIImage *uurImage = [UIImage imageNamed:@"kalender.jpg"];
    
    switch (indexPath.row){
        case 0:
            cell.imageView.image = afwdocImage;
            break;
        case 1:
            cell.imageView.image = bbImage;
            break;
        case 2:
            cell.imageView.image = dagImage;
            break;
        case 3:
            cell.imageView.image = exaImage;
            break;
        case 4:
            cell.imageView.image = dieImage;
            break;
        case 5:
            cell.imageView.image = plattegrondImage;
            break;
        case 6:
            cell.imageView.image = uurImage;
            break;
    }
    
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    return cell;
}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if ([[array objectAtIndex:indexPath.row] isEqual:@"Afwezige lectoren"]){
        self.afwDoc = [[AfwDocViewController alloc] initWithNibName:@"AfwDocViewController" bundle:nil];
        
        [self.navigationController pushViewController:afwDoc animated:YES];
        
    }else if ([[array objectAtIndex:indexPath.row] isEqual:@"Blackboard"]){
        self.bbm = [[BbmViewController alloc] initWithNibName:@"BbmViewController" bundle:nil];
        
        [self.navigationController pushViewController:bbm animated:YES];
                
    }else if ([[array objectAtIndex:indexPath.row] isEqual:@"Dagmenu"]){
        self.dag = [[DagViewController alloc] initWithNibName:@"DagViewController" bundle:nil];
        
        [self.navigationController pushViewController:dag animated:YES];
        
    }else if ([[array objectAtIndex:indexPath.row] isEqual:@"Examenrooster"]){
        self.exa = [[ExaViewController alloc] initWithNibName:@"ExaViewController" bundle:nil];
        
        [self.navigationController pushViewController:exa animated:YES];
        
    }else if ([[array objectAtIndex:indexPath.row] isEqual:@"Diensten"]){
        self.die = [[DieViewController alloc] initWithNibName:@"DieViewController" bundle:nil];
        
        [self.navigationController pushViewController:die animated:YES];
        
    }else if ([[array objectAtIndex:indexPath.row] isEqual:@"Plattegrond"]){
        self.plattegrond = [[PlattegrondViewController alloc] initWithNibName:@"PlattegrondViewController" bundle:nil];
        
        [self.navigationController pushViewController:plattegrond animated:YES];
        
    }else if ([[array objectAtIndex:indexPath.row] isEqual:@"Uurrooster"]){
        self.uur = [[UurViewController alloc] initWithNibName:@"UurViewController" bundle:nil];
        
        [self.navigationController pushViewController:uur animated:YES];
        
    }
    else{
        NSLog(@"fout");
    }

}

@end
